// $codepro.audit.disable numericLiterals
/**
 * This file was created by Julia Deeb for use in SpaceTrader
 */
import java.io.Serializable;
import java.util.Random;

/**
 * This class creates the Government each of the planets
 * 
 * @author Julia Deeb
 * @version 1.0
 */
public class Government implements Serializable {
    /**
     * This array represents all the possible governments for an industrial planet 
     */
    private final String[] industrial = { "Anarchy", "Democracy", "Dictatorship",
	    "Fascist State", "Feudal State", "Military State",
	    "Pacifist State", "State of Satori", "Capitalist",
	    "Corporate State", "Technocracy" };
    
    /**
     * This array represents all the possible governments for a non-industrial planet
     */
    private final String[] nonIndustrial = { "Anarchy", "Democracy", "Dictatorship",
	    "Fascist State", "Feudal State", "Military State",
	    "Pacifist State", "State of Satori", "Monarchy", "Theocracy",
	    "Socialist State" };
    
    /**
     * This array represents all the possible governments for a high tech planet
     */
    private final String[] hiTech = { "Anarchy", "Democracy", "Dictatorship",
	    "Fascist State", "Feudal State", "Military State",
	    "Pacifist State", "State of Satori", "Capitalist",
	    "Corporate State", "Technocracy", "Cybernetic" };
    
    /**
     * This string represents the type of the government
     */
    private String type;

    /**
     * This constructor creates the Government for each of the planets
     * 
     * @param techLevel
     *            the tech level of the planet
     */
    public Government(int techLevel) {
	calcType(techLevel);
    }

    /**
     * THis method calculates the type of government of the planet
     * 
     * @param level
     *            the tech level of the planet
     */
    private void calcType(int level) {
	String[] data;
	final Random rand = new Random();
	final int maxTechLevel = 7; // $codepro.audit.disable numericLiterals
	final int midTechLevel = 4; // $codepro.audit.disable numericLiterals
	if (level == maxTechLevel) {
	    data = hiTech;
	} else if (level >= midTechLevel) {
	    data = industrial;
	} else {
	    data = nonIndustrial;
	}
	final int index = rand.nextInt(data.length);
	type = data[index];
    }

    /**
     * this method returns a string represnting the type of government
     * 
     * @return a string representing the type of the government of the planet
     */
    public String getGovtType() {
	return type;
    }
    
    /**
     * This method returns a string representing the government class
     * @return A String representing the government class 
     */
    public String toString(){
	return this.toString();
    }
}
